package com.example.demo.config;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Aspect
@Component("myAspect")
public class MyAspect {

    //提取切点表达式
    @Pointcut(value = "execution(* com.example.demo.control.CollectionControl.*(..))")
    public void pointCut(){

    }

    @Before("pointCut()") //配置前置增强
    public void before(){
        System.out.println("前置增强");
    }

    @AfterReturning("pointCut()")
    public void after(){
        System.out.println("后置增强");
    }
    @Around("pointCut()")
    public Object around(ProceedingJoinPoint pjp) throws Throwable {
        System.out.println("环绕前增强");
        Object o =pjp.proceed();
        System.out.println("环绕后增强");
        return o;
    }

}
